﻿import os

from dotenv import load_dotenv
from langchain.chat_models import ChatOpenAI

load_dotenv("../ai.env")

api_base = os.getenv("OPENAI_API_BASE")
api_key = os.getenv("OPENAI_KEY")

llm = ChatOpenAI(
    model="gpt-4",
    temperature=0,
    openai_api_key=api_key,
    openai_api_base=api_base,
    max_tokens=512
)
for chunk in llm.stream("写一首关于秋天的诗歌"):
    print(chunk, end="\n", flush=False)
